<?php
class Default_Forms_LinkForm extends Zend_Form {
	function __construct($option = NULL) {
		$this->setAction('')
				->setMethod('POST')
				->setAttrib('class','form-horizontal');
		$name = $this->createElement('text', 'name');
		$name->setRequired ( true )
		            ->addFilter('StringTrim')
		            ->setAttrib('class','form-control')
		            ->setLabel('Tên');
		$url = $this->createElement ( 'text', 'url' );
		$url->setRequired ( true )
					->setAttrib('class','form-control')
					->setLabel('Đường dẫn');
		$description = $this->createElement ( 'textarea', 'description' );
		$description->setRequired ( true )
					->setAttrib('class','form-control')
					->setAttrib('rows','2')
					->setLabel('Mô tả ngắn');
		$submit = $this->createElement('submit','submit',array ('label' => $option['submit'] ,'class'	=>'btn btn-default'));
		 $cancel = $this->createElement('button','cancel',array ('label' => 'Hủy' ,'class'	=>'btn btn-default', 'onclick'	=> 'windown:location = "' . $option['cancel_link'] . '"'));
		$this->addElement($name)
				->addElement($url)
				->addElement($description)
				->addElement($description)
				->addElement($submit)
				->addElement($cancel);
		$this->setDecorators(array('FormElements',array('HtmlTag',array('tag'	=> 'div','width'=>'100%')),'form'));
		$this->setElementDecorators(array(
										'ViewHelper',
										'Errors',
										'Description',
										array(	
											array('data'	=> 'HtmlTag'),
											array('tag'		=> 'div','class'	=> 'col-md-6')),
										array('label',
											array('class'	=> 'col-md-3 control-label')),
										array(
											array('row'	=> 'HtmlTag',),
											array('class'=>'form-group')
		        						)
									)
								);
		$submit->setDecorators(array(
								'ViewHelper',
						       ));
		$cancel->setDecorators(array(
								'ViewHelper',
									)
						       );
		$this->addDisplayGroup(array('submit','cancel'),'action');
		$action = $this->getDisplayGroup('action');
		$action->setDecorators(array(
                'FormElements',
                'Fieldset',
                array('HtmlTag',array('tag'=>'div','class'	=> 'col-md-offset-3'))
        ));
	}
}